﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using SPMonkey.Core;
using SPMonkey.Resources;

namespace SPMonkey.Model
{
    public interface IBaseItem
    {
        SPListItem Item { get; set; }
    }

    public class BaseItem : IBaseItem
    {

        public BaseItem()
        { }

        public BaseItem(SPListItem item)
        { this.Item = item; }

        public int ID
        {
            get { return Item.ID; }
        }

        public Guid UniqueId
        {
            get { return Item.UniqueId; }
        }

        public string Title
        {
            get { return Item.GetValue("Title") as string; }
            set { Item.SetValue("Title", value); }
        }

        public DateTime? Modified
        {
            get { return Item.GetValue("Modified") as DateTime?; }
        }
        public DateTime? Created
        {
            get { return Item.GetValue("Created") as DateTime?; }
        }
        public string Editor
        {
            get { return Item.GetValue("Editor") as string; }
        }
        public string Author
        {
            get { return Item.GetValue("Author") as string; }
        }

        public void Update()
        {
            Item.Update();
        }
        public void SystemUpdate()
        {
            Item.SystemUpdate();
        }
        public void Delete()
        {
            Item.Delete();
        }
        public void UpdateUnsafe()
        {
            Item.UpdateUnsafe();
        }
        public void SystemUpdateUnsafe()
        {
            Item.SystemUpdateUnsafe();
        }
        public void DeleteUnsafe()
        {
            Item.DeleteUnsafe();
        }

        public object GetValue(string internalname)
        {
            return Item.GetValue(internalname);
        }

        public void SetValue(string internalname, object value)
        {
            Item.SetValue(internalname, value);
        }

        public SPListItem Item { get; set; }
    }


    //public class BaseGenericItem : IBaseItem
    //{
    //}
    //public class BaseDocumentItem : IBaseItem
    //{
    //}
    //public class BasePictureItem : IBaseItem
    //{
    //}
    //public class BaseAnnouncementItem : IBaseItem
    //{
    //}
    //public class BaseTaskItem : IBaseItem
    //{
    //}
    //public class BaseLinkItem : IBaseItem
    //{
    //}
}
